package com.iwhalecloud.bss.kite.cucc.web.service.accept.handler.attr;

import javax.annotation.Resource;

import com.iwhalecloud.bss.kite.client.api.scene.operate.IOperateSceneCommonService;
import com.iwhalecloud.bss.kite.common.util.KiteBeanUtils;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.dataservice.cache.ServiceOfferCache;
import com.iwhalecloud.bss.kite.dataservice.entity.ServiceOffer;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteSceneInst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iwhalecloud.bss.kite.client.vo.scene.CommonAttrVO;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.web.context.KiteWebContext;
import com.iwhalecloud.bss.kite.web.service.accept.attr.handler.AbstractAttrHandler;

import java.util.Objects;

@Service
public class OfferNameCommonAttrHandler extends AbstractAttrHandler {

    @Resource
    private IQuerySceneInstService querySceneInstService;
    @Autowired
    private IOperateSceneCommonService operateSceneCommonService;

    @Override
    public void init(CommonAttrVO commonAttr) {
        String sceneInstId = KiteWebContext.getContext().getCurrentSceneInstId();

        String offerName = querySceneInstService.getSceneInst(sceneInstId).getSceneInstName();
        KiteSceneInst sceneInst = querySceneInstService.getSceneInst(sceneInstId);
        if (Objects.nonNull(sceneInst)) {
            /**过户和用户信息变更不展示此字段
            if (KiteStringUtils.equalsAny(sceneInst.getServiceOfferId(), "1073", "2549")) {
                commonAttr.setShowType("H");
                KiteAttr commonAttrKite = KiteBeanUtils.transform(commonAttr, KiteAttr.class);
                operateSceneCommonService.setCommonAttr(sceneInstId, commonAttrKite);
            }*/
        }
        commonAttr.setValue(offerName);
        commonAttr.setValueDesc(offerName);
        setCommonAttr(commonAttr);
    }

}
